#ifndef ODN_SERIALIZABLE_H
#define ODN_SERIALIZABLE_H

#include "xmlParser.h"

// this open and parse the XML file:
XMLNode xMainNode=XMLNode::openFileHelper("PMMLModel.xml","PMML");

// this prints "RANK For <you>":
XMLNode xNode=xMainNode.getChildNode("Header");
printf("Application Name is: '%s'\n", xNode.getChildNode("Application").getAttribute("name"));

// this prints "Hello World!"
printf("Text inside Header tag is :'%s'\n", xNode.getText());

// this gets the number of "NumericPredictor" tags:
xNode=xMainNode.getChildNode("RegressionModel").getChildNode("RegressionTable");
int n=xNode.nChildNode("NumericPredictor");

// this prints the "coefficient" value for all the "NumericPredictor" tags:
int i,iterator=0;
for (i=0; i<n; i++)
printf("coeff %i=%s\n",i+1,xNode.getChildNode("NumericPredictor",&iterator).getAttribute("coefficient"));


template <class T>
class CSerialVar
{
	
public:
	
	enum VarType { V_INT, V_FLOAT, V_STRING };
	String 	m_sName;
	VarType m_eType;
	T& 		m_rVar;
};

class CSerializable
{

protected:
	
	enum VarType { V_INT, V_FLOAT, V_STRING };
	
	enum SerialType { S_STATIC, S_SAVE, S_NETWORK };

private:
	
	struct SerialVar {
		void* pVar;
		String sName;
		VarType eType;
	};
	
	Array<SerialVar> m_SerialVars;
	
	
public:
	
	virtual void serialize() = 0;
	
	void save()
	
protected:
	
	void addVariable(void* pVar, String sName, VarType eType)
	{
		
		SerialVar newVar;
		newVar.pVar = pVar;
		newVar.sName = sName;
		newVar.eType = eType;
		
		m_SerialVars.push_back(newVar);
		
	}
	
};

#endif //ODN_SERIALIZABLE_H